
#include "LightMatch.hpp"
#include "Function.hpp"
#include <string>

int main(int argc, char *argv[])
{
    auto device = torch::Device(torch::kCPU);
    torch::jit::script::Module module = torch::jit::load("/home/lenovo/_test/nn/pokemon/model.pt");
    module.to(device);
    module.eval();
    //read video
    cv::VideoCapture cap;
    // std::string xl="/home/lenovo/_gitee/video/video";
    // std::string xr=".avi";
    std::string x = "/home/lenovo/gitee/giteefiles/code_files/tasks/Judge/mycode/video/cv_output402.avi";
    while (true)
    {
        std::string path = x;
        cap.open(path);
        if (cap.isOpened() == false)
        {
            std::cerr << "Failed to load video from '" << path << "'\n";
            return -1;
        }
        //start to match light
        cv::Mat frame;
        //cv::namedWindow("disp", cv::WINDOW_AUTOSIZE);
        int frame_cnt = 0;
        Function F;
        while (true)
        {
            cap.read(frame); //取帧
            F.findlight(frame, module);
            cv::imshow("test", frame);
            // F.cutpics(frame, frame_cnt);
            cv::waitKey(10);
        }
        cv::destroyAllWindows();
        cap.release();
    }
    return 0;
}
